import { ElementAttrsType } from "./types";
/**
 * 
 * @param tagName 要创建的标签名称
 * @param attribute 要在标签上添加的属性
 * @returns 
 */
export function createElement(tagName: keyof HTMLElementTagNameMap, attribute?: ElementAttrsType): HTMLElement {
    const newElement = document.createElement(tagName);
    attribute && Object.keys(attribute).forEach(key => {
        newElement.setAttribute(key, attribute[key])
    })
    return newElement;
}